<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>系统人员</title>
    <script th:src="@{/layui/layui.js}" type="text/javascript"></script>
    <link th:href="@{/layui/css/layui.css}" rel="stylesheet" />
</head>
<body>


<div class="layui-panel" style="padding: 8px;">
    <fieldset class="layui-elem-field layui-border-blue">
        <legend>搜索信息</legend>
        <form class="layui-form layui-form-pane" style="margin: 20px;">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">名称</label>
                    <div class="layui-input-inline">
                        <input class="layui-input" type="text" name="name" id="demoReload" autocomplete="off" />
                    </div>
                </div>
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <a class="layui-btn layui-btn-primary" data-type="reload" lay-submit="" lay-filter="searchBtn">
                            <i class="layui-icon layui-icon-search"></i>
                            搜索
                        </a>
                    </div>
                </div>
            </div>
        </form>
    </fieldset>
    <div>
        <table id="RAEOrderTable" lay-filter="RAEOrderTable"></table>
    </div>
</div>

<script id="tool" type="text/html">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="yes">同意</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="no">不同意</a>
</script>

</script>



<script>
    var $;
    layui.use(['table','form','layer','jquery'],function() {
        var table = layui.table, form = layui.form,
            layer = layui.layer;
        $ = layui.jquery


        //加载表格
        table.render({
            elem: '#RAEOrderTable',
            height: 'full-160',
            page: true,
            url: '/system/raeo/find',
            cols: [
                [
                    {type: 'numbers', fixed: 'left', style: 'height:70px'},
                    {type: 'checkbox', fixed: 'left'},
                    {field: 'member', title: '下单会员', width: 120},
                    {field: 'orderTime', title: '下单时间', width: 130},
                    {field: 'state', title: '订单状态', width: 80,
                        templet:function (obj) {
                            var state=obj.state;
                            var str="";
                            if(state=="退货"){
                                str="<span style='color:#FF0000'>退货</span>"
                            }else if(state=="换货"){
                                str="<span style='color:#FFB800'>换货</span>"
                            }
                            return str;
                        }},
                    {field: 'orderAmount', title: '订单金额', width: 100},
                    {field: 'paidinAmount', title: '实付金额', width: 130},
                    {field: 'aymentTime', title: '支付时间', width: 130},
                    {field: 'oldCommodity', title: '已经支付的商品', width: 150},
                    {field: 'newCommodity', title: '需要更换成的商品', width: 150},
                    {field: 'consignee', title: '收货人', width: 100},
                    {field: 'oddNumbers', title: '物流单号'},
                    {field: 'channel', title: '物流渠道', width: 250},
                    {fixed: 'right', title: '操作', width: 150, align: 'center', toolbar: '#tool'},
                ]
            ]
        })

        //监听搜索按钮
        form.on('submit(searchBtn)', function (data) {
            var dataForm = data.field;

            table.reload('brandTable', {
                where: {
                    brandName:dataForm.name
                },
                page:{
                    curr:1
                }
            });
        });
        table.on('tool(RAEOrderTable)',function (obj) {
            var event=obj.event;

            if(event=='yes'){
                active.yes(obj.data)
            }else if(event=='no'){
                active.no(obj.data)
            }
        })

        var active = {
            yes: function (data) {
                $.ajax({
                    type:'post',
                    url:'/system/raeo/yes',
                    data:data,
                    dataType: 'json',
                    success:function (result) {
                        layer.msg(result.msg);
                        if(result.is) layui.table.reload('RAEOrderTable')
                    }
                })
            },
            no: function (data) {
                $.ajax({
                    type: 'post',
                    url: '/system/raeo/no',
                    data:data,
                    dataType: 'json',
                    success: function (result) {
                        layer.msg(result.msg)
                        if (result.is) layui.table.reload('RAEOrderTable');
                    }

                })

            },
        }

    });
</script>
</body>
</html>
